<template>
  <div>
    <div class="search" :style="width">
      <div class="location">
        <span class="home" @click="$router.push('/location')">{{
          cityName
        }}</span>
        <i class="iconfont icon-zelvxuanzefeiyongdaosanjiaoxingfandui"></i>
      </div>
      <div class="form">
        <i class="iconfont icon-sousuo"></i>
        <span class="text">请输入小区或地址</span>
      </div>
    </div>
    <slot></slot>
  </div>
</template>

<script>
export default {
  props: ['width'],
  data () {
    return {
      cityName: localStorage.getItem('cityName') === 'undefined' ? '上海' : localStorage.getItem('cityName')
    }
  }
}
</script>

<style lang="less" scoped>
div {
  display: flex;
  .search {
    display: flex;
    align-items: center;
    margin: 0 10px;
    padding: 5px 5px 5px 8px;
    border-radius: 3px;
    background-color: #fff;
    .home {
      width: 28px;
      height: 19px;
      color: #333;
      font-size: 14px;
      margin-right: 3px;
    }
    .icon-zelvxuanzefeiyongdaosanjiaoxingfandui {
      font-size: 12px;
      line-height: 19px;
    }
  }
  .form {
    flex: 1;
    margin-left: 12px;
    border-left: solid 1px #e5e5e5;
    line-height: 22px;
    .icon-sousuo {
      vertical-align: middle;
      padding: 0 2px 0 12px;
      color: #9c9fa1;
      font-size: 16px;
    }
    .text {
      padding-left: 4px;
      font-size: 13px;
      color: #9c9fa1;
    }
  }
}
</style>
